package org.edu.modules.growth.controller;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.edu.common.api.vo.Result;
import org.edu.common.system.base.controller.BaseController;
import org.edu.modules.growth.entity.VeJsczExamDetail;
import org.edu.modules.growth.service.IVeJsczExamDetailService;
import org.edu.modules.growth.service.IVeJsczExamProjectService;
import org.edu.modules.growth.vo.QueryCondition;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Api(tags="教职工评价管理--指标管理")
@RestController
@RequestMapping("jsczExamDetail")
@Slf4j
@AllArgsConstructor
public class VeJsczExamDetailController extends BaseController<VeJsczExamDetail, IVeJsczExamDetailService> {

    private IVeJsczExamDetailService mIVeJsczExamDetailService;

    private IVeJsczExamProjectService mIVeJsczExamProjectService ;


    @ApiOperation(value = "分页查询信息")
    @PostMapping("/selectPage")
    public Result<?> selectPage(@RequestBody QueryCondition queryCondition ) {
        return Result.OK(mIVeJsczExamDetailService.selectPage(queryCondition));
    }

    @ApiOperation(value = "查询当前的剩余可分配分数")
    @PostMapping("/isAdd")
    public Result<Integer> isAdd(@RequestParam("projectId")Long  projectId) {
        return Result.OK(mIVeJsczExamProjectService.availableScore(projectId)) ;
    }

    @ApiOperation(value = "保存与编辑指标管理")
    @PostMapping("/addOrUpdate")
    public Result<?> addOrUpdate(@RequestBody VeJsczExamDetail veJsczExamDetail) throws Exception {
        mIVeJsczExamDetailService.addAndupdate(veJsczExamDetail);
        return Result.OK() ;
    }

    @ApiOperation(value = "获取指标管理信息")
    @PostMapping("/getDetail")
    public Result<VeJsczExamDetail> getDetail(@RequestParam("id") Long id) {
        return Result.OK(mIVeJsczExamDetailService.getById(id));
    }

    @ApiOperation(value = "删除")
    @PostMapping("/removeById")
    public Result<?> removeById(@RequestParam("id") Long id) {
        return Result.OK( mIVeJsczExamDetailService.removeById(id) );
    }

    @ApiOperation(value = "批量删除")
    @PostMapping("/removeByIds")
    public Result<?> removeByIds(@RequestParam("ids") List<Long> ids) {
        return Result.OK(mIVeJsczExamDetailService.removeByIds(ids));
    }



}
